//
//  W_DealModel.m
//  Go!
//
//  Created by 凌風 on 16/7/14.
//  Copyright © 2016年 凌风. All rights reserved.
//

#import "W_DealModel.h"

@implementation W_DealModel

- (void)buildModelWithDict:(NSDictionary *)dict {
    if (dict && dict.count) {
        _imageURL = dict[@"tiny_image"];
        _marketPrice = dict[@"market_price"];
        _promotionPrice = dict[@"promotion_price"];
        _deal_Id = dict[@"deal_id"];
        _deal_name = dict[@"min_title"];;
        _deal_url = dict[@"deal_murl"];
        _deal_description = dict[@"description"];
        _sale_num = dict[@"sale_num"];
    } else {
        _imageURL = @"";
        _marketPrice = @"";
        _promotionPrice = @"";
        _deal_Id = @"";
        _deal_name = @"";
        _deal_url = @"";
        _deal_description = @"";
        _sale_num = @"";
    }
}

- (CGFloat)heightForDescriptionString {
    
    CGRect rect = [self.deal_description boundingRectWithSize:CGSizeMake(ScreenW - Size_W(64), MAXFLOAT) options:NSStringDrawingUsesFontLeading |  NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:Font(17)]} context:nil];
    
    return rect.size.height;
}

- (NSString *)description
{
    return [NSString stringWithFormat:@"{imageUrl = %@,\n marketPrice = %@,\n promotionPrice = %@,\n deal_Id = %@,\n deal_name = %@,\n deal_url = %@,\n deal_description = %@,\n sale_num = %@,\n}", _imageURL, _marketPrice, _promotionPrice, _deal_Id, _deal_name, _deal_url, _deal_description, _sale_num];
}

@end
